package com.gitee.feizns.quickstart.graalvm.js;

import com.gitee.feizns.quickstart.graalvm.Graalvm;
import com.gitee.feizns.quickstart.graalvm.Polyglot;
import lombok.RequiredArgsConstructor;

import java.util.Map;

/**
 * javascript
 * @author feizns
 * @since 2024/12/4
 */
@RequiredArgsConstructor
public class Js {

    /**
     * 创造js执行上下文
     * @return {@link Polyglot }
     */
    public static Polyglot create() {
        return Graalvm.js();
    }

    /**
     * 创造js执行上下文
     * @param variables 变量
     * @return {@link Polyglot }
     */
    public static Polyglot create(Map<String, Object> variables) {
        Polyglot js = create();
        js.putAll(variables);
        return js;
    }

}
